package com.iexbuy.ihg.wxapi;

import android.content.Context;

import com.tencent.mm.sdk.modelpay.PayReq;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;

/**
 * Created by chenguiban on 15/11/26.
 */
public class WeixinPay {

    //appid
    public static final String APP_ID = "wxf8e130a1cc83c3b6";

    //商户号
    public static final String MCH_ID = "1266073301";

    //appSecret
    public static final String APP_SECRET = "42b38a459a76a0ab43e4efd38393a0be";

    /**
     * 发起微信支付
     * @param context
     * @param appId
     * @param partnerId
     * @param prepayId
     * @param nonceStr
     * @param timestamp
     * @param packageValue
     * @param sign
     */
    public static void sendPayReq(Context context,
                                  String appId,
                                  String partnerId,
                                  String prepayId,
                                  String nonceStr,
                                  String timestamp,
                                  String packageValue,
                                  String sign) {

        final IWXAPI msgApi = WXAPIFactory.createWXAPI(context, null);
        msgApi.registerApp(appId);

        PayReq req = new PayReq();

        req.appId = appId;
        req.partnerId = partnerId;
        req.prepayId = prepayId;
        req.packageValue = packageValue;
        req.nonceStr = nonceStr;
        req.timeStamp = timestamp;
        req.sign = sign;

        msgApi.sendReq(req);
    }

}
